package lab02.test03;

public class Test {

    static void intersection(int[] a, int[] b) {

        int[] bitmap = new int[1000];

        for (int i = 0; i < a.length; i++) {

            bitmap[a[i] / 32 + 1] |= 1 << a[i] % 32 - 1;
        }


        for (int i = 0; i < b.length; i++) {

            if ((bitmap[b[i] / 32 + 1] & (1 << b[i] % 32 - 1)) == (1 << b[i] % 32 - 1)) {

                System.out.println(b[i]);

            }
        }

    }


    public static void main(String[] args) {


        int[] a = {1, 3, 35, 7, 2};
        int[] b = {1, 19, 5, 31000, 3};

        intersection(a, b);

    }
}
